.class public Lorg/microemu/app/util/DeviceEntry;
.super Ljava/lang/Object;
.source "DeviceEntry.java"


# instance fields
.field private canRemove:Z

.field private className:Ljava/lang/String;

.field private defaultDevice:Z

.field private descriptorLocation:Ljava/lang/String;

.field private emulatorContext:Lorg/microemu/EmulatorContext;

.field private fileName:Ljava/lang/String;

.field private name:Ljava/lang/String;


# direct methods
.method public constructor <init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V
    .locals 6
    .parameter "name"
    .parameter "fileName"
    .parameter "descriptorLocation"
    .parameter "defaultDevice"

    .prologue
    .line 61
    const/4 v5, 0x1

    move-object v0, p0

    move-object v1, p1

    move-object v2, p2

    move-object v3, p3

    move v4, p4

    invoke-direct/range {v0 .. v5}, Lorg/microemu/app/util/DeviceEntry;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZ)V

    .line 62
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZ)V
    .locals 0
    .parameter "name"
    .parameter "fileName"
    .parameter "descriptorLocation"
    .parameter "defaultDevice"
    .parameter "canRemove"

    .prologue
    .line 64
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 65
    iput-object p1, p0, Lorg/microemu/app/util/DeviceEntry;->name:Ljava/lang/String;

    .line 66
    iput-object p2, p0, Lorg/microemu/app/util/DeviceEntry;->fileName:Ljava/lang/String;

    .line 67
    iput-object p3, p0, Lorg/microemu/app/util/DeviceEntry;->descriptorLocation:Ljava/lang/String;

    .line 68
    iput-boolean p4, p0, Lorg/microemu/app/util/DeviceEntry;->defaultDevice:Z

    .line 69
    iput-boolean p5, p0, Lorg/microemu/app/util/DeviceEntry;->canRemove:Z

    .line 70
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;Lorg/microemu/EmulatorContext;)V
    .locals 6
    .parameter "name"
    .parameter "fileName"
    .parameter "defaultDevice"
    .parameter "className"
    .parameter "emulatorContext"

    .prologue
    .line 77
    const/4 v3, 0x0

    const/4 v5, 0x1

    move-object v0, p0

    move-object v1, p1

    move-object v2, p2

    move v4, p3

    invoke-direct/range {v0 .. v5}, Lorg/microemu/app/util/DeviceEntry;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZ)V

    .line 79
    iput-object p4, p0, Lorg/microemu/app/util/DeviceEntry;->className:Ljava/lang/String;

    .line 80
    iput-object p5, p0, Lorg/microemu/app/util/DeviceEntry;->emulatorContext:Lorg/microemu/EmulatorContext;

    .line 81
    return-void
.end method


# virtual methods
.method public canRemove()Z
    .locals 1

    .prologue
    .line 84
    iget-boolean v0, p0, Lorg/microemu/app/util/DeviceEntry;->canRemove:Z

    return v0
.end method

.method public equals(Lorg/microemu/app/util/DeviceEntry;)Z
    .locals 3
    .parameter "test"

    .prologue
    const/4 v2, 0x0

    .line 139
    if-nez p1, :cond_0

    move v0, v2

    .line 146
    :goto_0
    return v0

    .line 142
    :cond_0
    invoke-virtual {p1}, Lorg/microemu/app/util/DeviceEntry;->getDescriptorLocation()Ljava/lang/String;

    move-result-object v0

    invoke-virtual {p0}, Lorg/microemu/app/util/DeviceEntry;->getDescriptorLocation()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v0

    if-eqz v0, :cond_1

    .line 143
    const/4 v0, 0x1

    goto :goto_0

    :cond_1
    move v0, v2

    .line 146
    goto :goto_0
.end method

.method public getDescriptorLocation()Ljava/lang/String;
    .locals 10

    .prologue
    const/4 v7, 0x1

    .line 88
    iget-object v6, p0, Lorg/microemu/app/util/DeviceEntry;->descriptorLocation:Ljava/lang/String;

    if-nez v6, :cond_0

    .line 89
    new-array v5, v7, [Ljava/net/URL;

    .line 91
    .local v5, urls:[Ljava/net/URL;
    const/4 v6, 0x0

    :try_start_0
    new-instance v7, Ljava/io/File;

    invoke-static {}, Lorg/microemu/app/Config;->getConfigPath()Ljava/io/File;

    move-result-object v8

    iget-object v9, p0, Lorg/microemu/app/util/DeviceEntry;->fileName:Ljava/lang/String;

    invoke-direct {v7, v8, v9}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    invoke-virtual {v7}, Ljava/io/File;->toURI()Ljava/net/URI;

    move-result-object v7

    invoke-virtual {v7}, Ljava/net/URI;->toURL()Ljava/net/URL;

    move-result-object v7

    aput-object v7, v5, v6

    .line 92
    invoke-static {v5}, Lorg/microemu/app/Common;->createExtensionsClassLoader([Ljava/net/URL;)Ljava/lang/ClassLoader;

    move-result-object v0

    .line 93
    .local v0, classLoader:Ljava/lang/ClassLoader;
    iget-object v6, p0, Lorg/microemu/app/util/DeviceEntry;->className:Ljava/lang/String;

    const/4 v7, 0x1

    invoke-static {v6, v7, v0}, Ljava/lang/Class;->forName(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;

    move-result-object v2

    .line 94
    .local v2, deviceClass:Ljava/lang/Class;
    invoke-virtual {v2}, Ljava/lang/Class;->newInstance()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/barteo/emulator/device/Device;

    .line 96
    .local v1, device:Lcom/barteo/emulator/device/Device;
    new-instance v4, Lcom/barteo/emulator/EmulatorContext;

    iget-object v6, p0, Lorg/microemu/app/util/DeviceEntry;->emulatorContext:Lorg/microemu/EmulatorContext;

    invoke-direct {v4, v6}, Lcom/barteo/emulator/EmulatorContext;-><init>(Lorg/microemu/EmulatorContext;)V

    .line 98
    .local v4, oldContext:Lcom/barteo/emulator/EmulatorContext;
    invoke-virtual {v1, v4}, Lcom/barteo/emulator/device/Device;->init(Lcom/barteo/emulator/EmulatorContext;)V

    .line 99
    invoke-virtual {v1}, Lcom/barteo/emulator/device/Device;->getDescriptorLocation()Ljava/lang/String;

    move-result-object v6

    iput-object v6, p0, Lorg/microemu/app/util/DeviceEntry;->descriptorLocation:Ljava/lang/String;
    :try_end_0
    .catch Ljava/net/MalformedURLException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/lang/ClassNotFoundException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Ljava/lang/InstantiationException; {:try_start_0 .. :try_end_0} :catch_2
    .catch Ljava/lang/IllegalAccessException; {:try_start_0 .. :try_end_0} :catch_3

    .line 112
    .end local v5           #urls:[Ljava/net/URL;
    .end local v0           #classLoader:Ljava/lang/ClassLoader;
    .end local v2           #deviceClass:Ljava/lang/Class;
    .end local v1           #device:Lcom/barteo/emulator/device/Device;
    .end local v4           #oldContext:Lcom/barteo/emulator/EmulatorContext;
    :cond_0
    :goto_0
    iget-object v6, p0, Lorg/microemu/app/util/DeviceEntry;->descriptorLocation:Ljava/lang/String;

    return-object v6

    .line 100
    .restart local v5       #urls:[Ljava/net/URL;
    :catch_0
    move-exception v6

    move-object v3, v6

    .line 101
    .local v3, ex:Ljava/net/MalformedURLException;
    invoke-static {v3}, Lorg/microemu/log/Logger;->error(Ljava/lang/Throwable;)V

    goto :goto_0

    .line 102
    .end local v3           #ex:Ljava/net/MalformedURLException;
    :catch_1
    move-exception v6

    move-object v3, v6

    .line 103
    .local v3, ex:Ljava/lang/ClassNotFoundException;
    invoke-static {v3}, Lorg/microemu/log/Logger;->error(Ljava/lang/Throwable;)V

    goto :goto_0

    .line 104
    .end local v3           #ex:Ljava/lang/ClassNotFoundException;
    :catch_2
    move-exception v6

    move-object v3, v6

    .line 105
    .local v3, ex:Ljava/lang/InstantiationException;
    invoke-static {v3}, Lorg/microemu/log/Logger;->error(Ljava/lang/Throwable;)V

    goto :goto_0

    .line 106
    .end local v3           #ex:Ljava/lang/InstantiationException;
    :catch_3
    move-exception v6

    move-object v3, v6

    .line 107
    .local v3, ex:Ljava/lang/IllegalAccessException;
    invoke-static {v3}, Lorg/microemu/log/Logger;->error(Ljava/lang/Throwable;)V

    goto :goto_0
.end method

.method public getFileName()Ljava/lang/String;
    .locals 1

    .prologue
    .line 116
    iget-object v0, p0, Lorg/microemu/app/util/DeviceEntry;->fileName:Ljava/lang/String;

    return-object v0
.end method

.method public getName()Ljava/lang/String;
    .locals 1

    .prologue
    .line 127
    iget-object v0, p0, Lorg/microemu/app/util/DeviceEntry;->name:Ljava/lang/String;

    return-object v0
.end method

.method public isDefaultDevice()Z
    .locals 1

    .prologue
    .line 131
    iget-boolean v0, p0, Lorg/microemu/app/util/DeviceEntry;->defaultDevice:Z

    return v0
.end method

.method public setDefaultDevice(Z)V
    .locals 0
    .parameter "b"

    .prologue
    .line 135
    iput-boolean p1, p0, Lorg/microemu/app/util/DeviceEntry;->defaultDevice:Z

    .line 136
    return-void
.end method

.method public setFileName(Ljava/lang/String;)V
    .locals 0
    .parameter "fileName"

    .prologue
    .line 123
    iput-object p1, p0, Lorg/microemu/app/util/DeviceEntry;->fileName:Ljava/lang/String;

    .line 124
    return-void
.end method

.method public toString()Ljava/lang/String;
    .locals 2

    .prologue
    .line 150
    iget-boolean v0, p0, Lorg/microemu/app/util/DeviceEntry;->defaultDevice:Z

    if-eqz v0, :cond_0

    .line 151
    new-instance v0, Ljava/lang/StringBuffer;

    invoke-direct {v0}, Ljava/lang/StringBuffer;-><init>()V

    iget-object v1, p0, Lorg/microemu/app/util/DeviceEntry;->name:Ljava/lang/String;

    invoke-virtual {v0, v1}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    move-result-object v0

    const-string v1, " (default)"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuffer;->toString()Ljava/lang/String;

    move-result-object v0

    .line 153
    :goto_0
    return-object v0

    :cond_0
    iget-object v0, p0, Lorg/microemu/app/util/DeviceEntry;->name:Ljava/lang/String;

    goto :goto_0
.end method
